package com.zhike.b2b.util;

import com.zhike.b2b.model.ClassVo;
import com.zhike.b2b.model.NewsVo;

/**
 * 各种业务实体类别的工具类
 * @author IBM
 */
public class ClassUtil {

	 /**
	  * 获取类别的html链接
	  * @param mcv
	  * @param pageNo
	  * @return
	  */
	 public static String getListUrl(ClassVo mcv,int pageNo)
	 {
		 String listRule = mcv.getListRule();
		 if (listRule.indexOf("{class_id}") != -1)
			 listRule = listRule.replace("{class_id}", mcv.getClassId());
		 if (listRule.indexOf("{pageindex}") != -1)
			 listRule = listRule.replace("{pageindex}", Integer.toString(pageNo));
		 String url = mcv.getStorePath()+listRule;
		 return url;
	 }
	 
	 /**
	  * 获取类别的html链接(没有页号)
	  * @param mcv
	  * @param pageNo
	  * @return
	  */
	 public static String getListUrl(ClassVo mcv)
	 {
		 String listRule = mcv.getListRule();
		 if (listRule.indexOf("{class_id}") != -1)
			 listRule = listRule.replace("{class_id}", mcv.getClassId());
		 String url = mcv.getStorePath()+listRule;
		 return url;
	 }
	 
	    /**
		 * 获取业务实体的html链接
		 * 
		 * @param cv
		 * @param pageNo
		 * @return
		 */
		public static String getObjUrl(ClassVo cv,String objId ) {
			String articleRule = cv.getArticleRule();
			if (articleRule.indexOf("{class_id}") != -1)
				articleRule = articleRule.replace("{class_id}", cv.getClassId());
			if (articleRule.indexOf("{fid}") != -1)
				articleRule = articleRule.replace("{fid}", objId);
			String url = cv.getStorePath() + articleRule;
			return url;
		}
}
